#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    vector<int> temp;
    set<vector<int>> res;
    vector<vector<int>> ans;
    int size;
    vector<int>* visited;
    void dfs(vector<int> &nums,int depth){
      if (depth==size){
        if (res.count(ans)==0){
          ans.push_back(temp);
        }
        return;
      }
      
      for(int i=0;i<size;i++){
        if (visited[i]==0){
          visited[i]=1;
          temp.push_back(nums[i]);
          dfs(nums,depth);
          visited[i]=0;
        }
      }


    }
    vector<vector<int>> permuteUnique(vector<int>& nums) {
      size = nums.size(); visited = new vector<int>(size,0);
      dfs(nums,0);
      return ans;
    }
};
void show(vector<vector<int>> nums){
  int size = nums.size();
  int len = nums[0].size();
  for(int i=0;i<size;i++)
  {
    for(int j=0;j<len;j++)
      cout<<nums[i][j];
    cout<<endl;
  }
}

int main()
{
  Solution s;
  vector<int> nums = {1,2,3};
  vector<vector<int>> res  =  s.permuteUnique(nums)
  return 0;
}